<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>个人设置</title>
    <link rel="stylesheet" href="../../layui/css/layui.css">
    <link rel="stylesheet" href="../../css/iconfont.css">
    <link rel="stylesheet" href="../../css/base.css">
    <script src="../../js/jquery-1.11.0.js"></script>
    <script src="../../layui/layui.js"></script>
    <script src="../../js/frameAll.js"></script>
    <style>
        .layui-form {
            margin-top: 30px;
        }
    </style>
</head>
<body>
<div class="cBody">
    <form class="layui-form" lay-filter="infoForm">
        <div class="layui-form-item">
            <label class="layui-form-label">姓&emsp;名 : </label>
            <div class="layui-input-inline shortInput">
                <input type="text" name="comployeeName" autocomplete="off" class="layui-input"
                       placeholder="请输入您的姓名" lay-verify="name">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">年&emsp;龄 : </label>
            <div class="layui-input-inline shortInput">
                <input type="text" name="age" autocomplete="off" class="layui-input"
                       placeholder="请输入您的年龄" lay-verify="age">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">部&emsp;门 : </label>
            <div class="layui-input-inline shortInput">
                <input type="text" name="dept" autocomplete="off" class="layui-input"
                       readOnly="true">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">现任职务 : </label>
            <div class="layui-input-inline shortInput">
                <input type="text" name="profession" autocomplete="off" class="layui-input"
                       readOnly="true">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">联系方式 : </label>
            <div class="layui-input-inline shortInput">
                <input type="text" name="phone" autocomplete="off" class="layui-input"
                       placeholder="请输入您的联系方式" lay-verify="phone">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">家庭地址 : </label>
            <div class="layui-input-inline shortInput">
                <input type="text" name="address" autocomplete="off" class="layui-input"
                       placeholder="请输入您的家庭地址" lay-verify="">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">性&emsp;别 : </label>
            <div class="layui-input-block">
                <input type="radio" name="sex" value="男" title="男">
                <input type="radio" name="sex" value="女" title="女">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-radius" lay-submit lay-filter="submitBut">
                    修&nbsp;&nbsp;&nbsp;&nbsp;改
                </button>
                <button class="layui-btn layui-btn-radius layui-btn-primary" id="primary" type="button">重&nbsp;&nbsp;&nbsp;&nbsp;置</button>
            </div>
        </div>
    </form>
</div>
<script>
    layui.use('form', function () {
        var form = layui.form;

        //初始化
        function loadData() {
            $.ajax({
                type: "get",
                url: "/fixedAsset/getUser.do",
                data: {comployee: "1"},
                dataType: "Json",
                success: function (data) {
                    if (data.data) {
                        var comployee = data.data.comployee;
                        form.val('infoForm', {
                            comployeeName: comployee.comployeeName,
                            sex: comployee.sex,
                            age: comployee.age,
                            dept: comployee.dept,
                            profession: comployee.profession,
                            address: comployee.address,
                            phone: comployee.phone,
                        });
                    }
                },
                error: function () {
                    top.location.href = "../../login.html";
                }
            });
        }

        loadData();
        //监听提交
        form.on('submit(submitBut)', function (data) {
            var field = data.field;
            $.ajax({
                type: "post",
                url: "/fixedAsset/update.do",
                data: field,
                dataType: "Json",
                success: function (data) {
                    switch (data.code) {
                        case 0:
                            yesMsg(data.message);
                            break;
                        case 1:
                            noMsg(data.message);
                            break;
                        default:
                    }
                },
                error: function () {
                    noMsg("连接服务器失败");
                }
            })
            ;
            return false;
        });
        //重置监听
        $("#primary").click(function () {
            yesMsg("已重置");
            loadData();
        })
    });
</script>
</body>
</html>